package it.polimi.TravelDream.ejb.entities;

import it.polimi.TravelDream.ejb.dtos.ExcursionDTO;

import java.io.Serializable;
import java.lang.String;
import java.util.List;

import javax.persistence.*;

/**
 * Entity implementation class for Entity: Excursion
 *
 */
@Entity
@Table(name="Excursions")
//Dovrei fare una query dove posso selezionare in base al nome del progetto
//SELECT e FROM Excursion e WHERE e.list_of_package.contains(:trave NON NE HO IDEA
@NamedQueries({
	@NamedQuery(name = Excursion.FIND_EXCURSION_BY_NATION , query = "SELECT e FROM Excursion e WHERE e.nation = :nation"),
	@NamedQuery(name = Excursion.FIND_EXCURSION_BY_EXCURSIONID, query = "SELECT e FROM Excursion e WHERE e.excursionID = :excursionID"),
	@NamedQuery(name = Excursion.FIND_EXCURSION_BY_NAME, query = "SELECT e FROM Excursion e WHERE e.name = :name"),
	@NamedQuery(name = Excursion.FIND_EXCURSION_BY_NAME_AND_NATION, query = "SELECT e FROM Excursion e WHERE e.name = :name and e.nation= :nation"),
	@NamedQuery(name = Excursion.FIND_ALL_EXCURSIONS, query = "SELECT e FROM Excursion e")
})
public class Excursion implements Serializable {

	   
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int excursionID;
	@Column(nullable = false, length=30)
	private String name;
	@Column(nullable = false, length=200)
	private String description;
	@Column(nullable = false, length=45)
	private String nation;
	@Column(nullable = false)
	private double price;
	private int placesAvailable;

	//Pacchetti che contengono questa escursione
	@ManyToMany(mappedBy = "excursions")
	private List <UserPackage> list_of_userpackage;
	
	//Pacchetti che contengono questa escursione
	@ManyToMany(mappedBy = "excursions")
	private List <BasicPackage> list_of_package;

	public Excursion() {
	}  
	
	public Excursion(ExcursionDTO excursionDTO) {
		super();
		this.name = excursionDTO.getName();
		this.description = excursionDTO.getDescription();
		this.nation = excursionDTO.getNation();
		this.price = excursionDTO.getPrice();
		this.placesAvailable = excursionDTO.getPlacesAvailable();
	}  
	public static final String FIND_EXCURSION_BY_NATION = "Excursion.findExcursionByNation";
	public static final String FIND_EXCURSION_BY_EXCURSIONID = "Excursion.findExcursionByExcursionId";
	public static final String FIND_EXCURSION_BY_NAME = "Excursion.findExcursionsByName";
	public static final String FIND_EXCURSION_BY_NAME_AND_NATION = "Excursion.findExcursionsByNameAndNation";
	public static final String FIND_ALL_EXCURSIONS = "Excursion.findAllExcursions";
	private static final long serialVersionUID = 1L;
	
	public int getExcursionID() {
		return this.excursionID;
	}

	public void setExcursionID(int excursionID) {
		this.excursionID = excursionID;
	}   
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}   
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}   
	public String getNation() {
		return this.nation;
	}

	public void setNation(String nation) {
		this.nation = nation;
	}   
	public double getPrice() {
		return this.price;
	}

	public void setPrice(double price) {
		this.price = price;
	}   
	public int getPlacesAvailable() {
		return this.placesAvailable;
	}

	public void setPlacesAvailable(int placesAvailable) {
		this.placesAvailable = placesAvailable;
	}

	public List<UserPackage> getList_of_userpackage() {
		return list_of_userpackage;
	}

	public void setList_of_userpackage(List<UserPackage> list_of_userpackage) {
		this.list_of_userpackage = list_of_userpackage;
	}

	public List<BasicPackage> getList_of_package() {
		return list_of_package;
	}

	public void setList_of_package(List<BasicPackage> list_of_package) {
		this.list_of_package = list_of_package;
	}
   
}
